import 'package:flutter/material.dart';

import 'screens/account/account_detail_screen.dart';
import 'screens/manage/business_level_screen.dart';
import 'screens/manage/business_type_screen.dart';
import 'screens/account/account_password_change.dart';
import 'screens/order/order_confirm_screen.dart';
import 'screens/group/group_history_screen.dart';
import 'screens/home/home_search_screen.dart';
import 'screens/order/logistics_page.dart';
import 'screens/cart/cart_page.dart';
import 'screens/home/news_detail_page.dart';
import 'screens/home/news_page.dart';
import 'screens/main/main_page.dart';
import 'screens/address/address_edit_page.dart';
import 'screens/address/address_page.dart';
import 'screens/address/address_region_page.dart';
import 'screens/account/account_page.dart';
import 'screens/mine/forget_page.dart';
import 'screens/manage/bank_edit_page.dart';
import 'screens/manage/bank_page.dart';
import 'screens/manage/bank_type_page.dart';
import 'screens/manage/business_condition_page.dart';
import 'screens/manage/store_manage_page.dart';
import 'screens/order/order_detail_page.dart';
import 'screens/order/order_page.dart';
import 'screens/mine/qrcode_page.dart';
import 'screens/mine/store_apply_page.dart';
import 'screens/mine/user_mobile_page.dart';
import 'screens/mine/user_nickname_page.dart';
import 'screens/mine/user_password_page.dart';
import 'screens/mine/user_renew_page.dart';
import 'screens/mine/webview_page.dart';
import 'screens/point/point_history_screen.dart';
import 'screens/point/point_transfer_history_screen.dart';
import 'screens/point/point_transfer_query_screen.dart';
import 'screens/point/point_transfer_screen.dart';
import 'screens/product/product_area_pg_screen.dart';
import 'screens/splash/splash_page.dart';
import 'screens/product/product_page.dart';
import 'screens/mine/auth_page.dart';
import 'screens/mine/invite_page.dart';
import 'screens/mine/invited_page.dart';
import 'screens/mine/login_page.dart';
import 'screens/mine/register_page.dart';
import 'screens/mine/setting_page.dart';
import 'screens/mine/user_page.dart';
import 'screens/manage/withdraw_account_page.dart';
import 'screens/manage/withdraw_edit_page.dart';
import 'screens/manage/withdraw_page.dart';
import 'screens/store/store_category_screen.dart';
import 'screens/store/store_screen.dart';
import 'screens/group/group_port_screen.dart';
import 'screens/home/home_category_screen.dart';
import 'screens/home/home_store_screen.dart';
import 'screens/point/point_exchange_screen.dart';
import 'screens/product/product_area_screen.dart';
import 'screens/product/product_category_screen.dart';

class Routes {
  static GlobalKey<NavigatorState> navigatorKey = GlobalKey();

  static Route<dynamic> generateRoute(RouteSettings settings) {
    debugPrint('----------> Router ${settings.name} ${settings.arguments} <----------');

    final routes = <String, WidgetBuilder>{
      SplashPage.routeName: (context) => SplashPage(),
      MainPage.routeName: (context) => MainPage(),
      SettingPage.routeName: (context) => SettingPage(args: settings.arguments),
      LoginPage.routeName: (context) => LoginPage(args: settings.arguments),
      RegisterPage.routeName: (context) => RegisterPage(),
      ProductPage.routeName: (context) => ProductPage(args: settings.arguments),
      OrderPage.routeName: (context) => OrderPage(args: settings.arguments),
      OrderDetailPage.routeName: (context) => OrderDetailPage(args: settings.arguments),
      AddressPage.routeName: (context) => AddressPage(args: settings.arguments ?? false),
      AddressEditPage.routeName: (context) => AddressEditPage(args: settings.arguments),
      AddressRegionPage.routeName: (context) => AddressRegionPage(args: settings.arguments),
      UserPage.routeName: (context) => UserPage(args: settings.arguments),
      UserNicknamePage.routeName: (context) => UserNicknamePage(args: settings.arguments),
      UserMobilePage.routeName: (context) => UserMobilePage(args: settings.arguments),
      UserPasswordPage.routeName: (context) => UserPasswordPage(),
      StoreScreen.routeName: (context) => StoreScreen(args: settings.arguments),
      StoreManagePage.routeName: (context) => StoreManagePage(args: settings.arguments),
      StoreApplyPage.routeName: (context) => StoreApplyPage(args: settings.arguments),
      BankPage.routeName: (context) => BankPage(args: settings.arguments ?? false),
      BankEditPage.routeName: (context) => BankEditPage(args: settings.arguments),
      BankTypePage.routeName: (context) => BankTypePage(),
      BusinessTypeScreen.routeName: (context) => BusinessTypeScreen(),
      BusinessLevelScreen.routeName: (context) => BusinessLevelScreen(args: settings.arguments),
      BusinessConditionPage.routeName: (context) => BusinessConditionPage(args: settings.arguments),
      WithdrawPage.routeName: (context) => WithdrawPage(args: settings.arguments),
      WithdrawEditPage.routeName: (context) => WithdrawEditPage(),
      WithdrawAccountPage.routeName: (context) => WithdrawAccountPage(),
      AccountPage.routeName: (context) => AccountPage(args: settings.arguments),
      AuthPage.routeName: (context) => AuthPage(args: settings.arguments),
      InvitePage.routeName: (context) => InvitePage(args: settings.arguments),
      InvitedPage.routeName: (context) => InvitedPage(args: settings.arguments),
      UserRenewPage.routeName: (context) => UserRenewPage(args: settings.arguments),
      QrcodePage.routeName: (context) => QrcodePage(),
      ForgetPage.routeName: (context) => ForgetPage(),
      NewsPage.routeName: (context) => NewsPage(),
      NewsDetailPage.routeName: (context) => NewsDetailPage(args: settings.arguments),
      CartPage.routeName: (context) => CartPage(),
      WebViewPage.routeName: (context) => WebViewPage(args: settings.arguments),
      LogisticsPage.routeName: (context) => LogisticsPage(args: settings.arguments),
      HomeSearchScreen.routeName: (context) => HomeSearchScreen(args: settings.arguments),
      HomeStoreScreen.routeName: (context) => HomeStoreScreen(),
      HomeCategoryScreen.routeName: (context) => HomeCategoryScreen(args: settings.arguments),
      StoreCategoryScreen.routeName: (context) => StoreCategoryScreen(args: settings.arguments),
      ProductAreaScreen.routeName: (context) => ProductAreaScreen(args: settings.arguments),
      ProductCategoryScreen.routeName: (context) => ProductCategoryScreen(args: settings.arguments),
      GroupPortScreen.routeName: (context) => GroupPortScreen(args: settings.arguments),
      GroupHistoryScreen.routeName: (context) => GroupHistoryScreen(),
      OrderConfirmScreen.routeName: (context) => OrderConfirmScreen(args: settings.arguments),
      ProductAreaPgScreen.routeName: (context) => ProductAreaPgScreen(args: settings.arguments),
      PointExchangeScreen.routeName: (context) => PointExchangeScreen(),
      PointTransferScreen.routeName: (context) => PointTransferScreen(),
      PointTransferQueryScreen.routeName: (context) => PointTransferQueryScreen(),
      PointTransferHistoryScreen.routeName: (context) => PointTransferHistoryScreen(args: settings.arguments),
      AccountPasswordChange.routeName: (context) => AccountPasswordChange(args: settings.arguments),
      PointHistroyScreen.routeName: (context) => PointHistroyScreen(),
      AccountDetailScreen.routeName: (context) => AccountDetailScreen(args: settings.arguments),
    };

    final widgetBuilder = routes[settings.name];
    return widgetBuilder == null
        ? null
        : MaterialPageRoute(builder: (context) => widgetBuilder(context), settings: settings);
  }
}
